package com.ssps.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author Hala Zhou
 * @time 2020/07/21 15:07:26
 */
@Configuration
public class CORSConfig implements WebMvcConfigurer {
    /**
     * 允许跨域请求
     * 允许携带cookie
     *
     * @param registry
     */
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOrigins("*").allowCredentials(true);
    }

    /**
     * 图片资源访问
     *
     * @param registry
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/upload/**")
                .addResourceLocations("file:C:/Users/周晨/Desktop/upload/");

      registry.addResourceHandler ("/upload/**").addResourceLocations ("file:C:/Users/刘歌/Desktop/upload/");
    }


}
